package cn.manyufun.myf.ui.user.presenter;

import cn.manyufun.myf.bean.RegisterBean;
import cn.manyufun.myf.bean.VerifyCodeBean;
import cn.manyufun.myf.common.base.BasePresenter;
import cn.manyufun.myf.common.baserx.RxSubscriber;
import cn.manyufun.myf.ui.user.activity.RegisterAcitivty;
import cn.manyufun.myf.ui.user.model.RegisterModel;

/**
 * Created by Xiao on 2018-02-24.
 */

public class RegisterPresenter extends BasePresenter<RegisterAcitivty, RegisterModel> {
    public void sendVerifyCode(String phone) {
        mRxManage.add(mModel.sendVerifyCode(phone)
                .subscribe(new RxSubscriber<VerifyCodeBean>(mContext, false) {
                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    protected void _onNext(VerifyCodeBean bean) {
                        mView.returnVerifyCode(bean);
                    }

                    @Override
                    protected void _onError(String message) {
                    }
                }));
    }

    public void requestRegister(String username, String pwd, String verifyCode) {
        mRxManage.add(mModel.requestRegister(username, pwd, verifyCode)
                .subscribe(new RxSubscriber<RegisterBean>(mContext, false) {
                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    protected void _onNext(RegisterBean bean) {
                        mView.responseRegister(bean);
                    }

                    @Override
                    protected void _onError(String message) {
                    }
                }));

    }
}
